<?php

session_start();

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Realivent Login</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link type="text/css" rel="stylesheet" href="new_style.css">

</head>



<body>

<center>

<?php



//echo "redirect=";

//echo $_POST["redirect"];

//echo "<br>";



if ($_POST["redirect"]!='')

$redirect = $_POST["redirect"];

else

$redirect = 'accounts/index.php';



$username='';

$password='';



if(isset($_POST['username']))

$username = $_POST['username'];

if(isset($_POST['password']))

$password = md5($_POST['password']);



if($username && $password)

{

	include "db/opendb.php";

	$query = "select Verified, Role, Password, ID from Users where Username='".$username."'";

	//echo $query;

	$result = mysql_query($query) or die ("SQL Error".mysql_error());

	$row=mysql_fetch_assoc($result);

	if(!$row['Password'] || $row['Password'] !=$password)

	{

		$message = "The login information you have supplied is incorrect! <br> Please try again!";

		echo "<meta http-equiv=refresh content=1;URL=new_login.php>";

		//include "information.php";



	}

	else if($row['Verified'] != '1')

	{

		$message = "This user account is not verified! <br> Please try again!";

		echo "<meta http-equiv=refresh content=1;URL=new_login.php>";

	}

	else

	{

		$_SESSION['username']=$username;

		$_SESSION['role']=$row["Role"];

		$_SESSION['id']=$row["ID"];


		//set the type session variable : basic/single/starter/pro/power

		$query = "select Type from Users where Username='".$username."'";
		//echo $query;
		$result = mysql_query($query) or die ("SQL Error".mysql_error());
		$row=mysql_fetch_assoc($result);
		$_SESSION['type']=$row['Type'];


		/* if($_POST['remember'] === 'Yes')

		{

		$expire = time() + (86400*365);

		setcookie('username', $username, $expire);

		setcookie('pass', $password, $expire);

		} */



		$message = "Login success! <br> Please wait while we redirect you to your page! ";



		if(isset($redirect))

		{



			echo "<meta http-equiv=refresh content=1;URL=".$redirect.">";

			//include "information.php";

			//include "db/closedb.php";

		}

		else

		{

			echo "<meta http-equiv=refresh content=1;URL=accounts/account.php>";

		}

	}

}

else

{

	//header("location: login.php");

	$show_form = true;

}

?>



<TR><TD><?php include('topnav.php'); ?></TD></TR>

  <tr>

    <td width=100% valign="top" style="height:300px;">





	<table width="700px"  border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td>

	<?php

	if(!$show_form)

	{

		echo $message;

	}

	else

	{

	?>

	<Div  style="padding:30px; font-family:Verdana, Arial, Helvetica, sans-serif;">

	<form action="new_login.php" method="post" enctype="multipart/form-data" name="login">

	<input name="redirect" type="hidden" value="<?php echo $_GET['redirect'] ?>">

	  <table id=form_container width="100%"  border="0" cellspacing="0" cellpadding="5">

			<tr>

			<td height=30px colspan="2" id=form_header>&nbsp;&nbsp;&nbsp;&nbsp;Account Login</td>

		  </tr>

		  <tr>

			<td width="38%" align="right">Username: </td>

			<td width="62%"><input name="username" type="text"></td>

		  </tr>

		  <tr>

			<td align="right">Password: </td>

			<td><input name="password" type="password"></td>

		  </tr>

		  <!-- <tr>

			<td colspan=2 align=center>Remember me <input name="remember" type="checkbox" value="Yes"></td>

		  </tr>-->

		  <tr>

			<td colspan="2" style="padding-right:50px;" align="right"><input name="submit" type="submit" value="Login"></td>

		  </tr>

		   <tr>

			<td colspan="2" style="padding-right:50px;" align="left"><a href=new_forget_password.php>Forget Password?</a></td>

		  </tr>

		</table>

</form>

</DIV>







	<?php

	}

	?>



	</td>

    <TD width="50%" valign="top">



<!--	<Div class="style11" style="padding:30px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 18px;">

			  <span class="style2">Not Registered?</span>              <br>

              <br>

              <a href="http://realivent.com/register/new_register.php">Register </a>for a new account.</DIV>-->
              
    <Div class="style11" style="padding:30px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 18px;">

			  <span class="style2">Not Registered?</span>              <br>

              <br>

              <a href="#">Register </a>for a new account.</DIV>

	</TD>

  </tr>

</table>


<?php include('new_footer.php'); ?>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
	var pageTracker = _gat._getTracker("UA-2413582-1");
	pageTracker._trackPageview();
} catch(err) {}</script>

</body>

</html>